import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import 线程.MyThread;
import 线程.MyThreadimpRunnable;

import java.io.*;

public class Main {

    public static void testMyKVDB() throws IOException {
        MyKVDB myKVDB = new MyKVDB("./","date");

        String str = "谢文武";
        String str1 = "技术改变生活！";
        myKVDB.put("签名",str1.getBytes());
        myKVDB.put("name",str.getBytes());

        InputStream in = new ByteArrayInputStream(myKVDB.get("签名"));
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
        System.out.println(bufferedReader.readLine());
        myKVDB.flush();
    }

    public static void testJSON() throws JsonProcessingException {
        User user = new User();
        user.setName("上课了放假啊来看电视");
        user.setAge(23);
        user.setSex("上课啦赶紧拉开");
        ObjectMapper mapper = new ObjectMapper();
        mapper.enable(SerializationFeature.INDENT_OUTPUT);

        String str = mapper.writeValueAsString(user);
        System.out.println(str);
    }



    public static void main(String[] args) throws IOException {
        testMyKVDB();
        testJSON();
        MyThread myThread = new MyThread();
        myThread.start();

        Thread threadimpRunnable = new Thread(new MyThreadimpRunnable());
        threadimpRunnable.start();
    }
}
